package org.arclib.examples.core;

import java.io.IOException;

import org.arclib.ArcGame;
import org.arclib.math.Size;
import org.arclib.sound.Music;
import org.arclib.sound.Sound;
import org.arclib.sound.SoundStore;
import org.lwjgl.input.Keyboard;

public class SoundTest extends ArcGame
{
	/** The sound to be played */
	private Sound charlie;
	/** The music to be played */
	private Music music;

	protected SoundTest(String argT, Size argS, boolean argFS)
			throws IOException
	{
		super(argT, argS, argFS);

		SoundStore.get().setMaxSources(32);

		charlie = new Sound("testbin/laser.wav");

		music = new Music("testbin/remix.ogg");

		music.play();
		// TODO Auto-generated constructor stub
	}

	public void process()
	{

		if (Keyboard.isKeyDown(Keyboard.KEY_RETURN))
		{
			charlie.play(1.0f, 1.0f);
		}
		if (Keyboard.isKeyDown(Keyboard.KEY_P))
		{
			if (music.playing())
			{
				music.pause();
			} else
			{
				music.resume();
			}
		}

		// music.loop();
	}

	public void shutdown()
	{
		music.stop();
		charlie.stop();
	}

	/**
	 * @param args
	 * @throws IOException
	 * @throws InterruptedException
	 */
	public static void main(String[] args) throws IOException,
			InterruptedException
	{
		// TODO Auto-generated method stub
		SoundTest t = new SoundTest("Sound Test", Size.d640x480, false);
		t.run();
	}

}
